package com.ynny.chapter02.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/hello")
public class HelloController {
    // 得到日志对象
    private static Logger logger = LoggerFactory.getLogger(HelloController.class);

    @RequestMapping("/logger")
    public void logger() {
        String msg = "日志";
        // 按照从低到高的顺序打印日志级别
        logger.trace("trace 的" + msg);
        logger.debug("debug 的" + msg);
        logger.info("info 的" + msg);
        logger.warn("warn 的" + msg);
        logger.error("error 的" + msg);

//        logger.info("HelloController----->logger----->"+msg);


    }

    @GetMapping
    public Map hello() {
        HashMap hashMap = new HashMap();

        hashMap.put("message", "Hello World");
        return hashMap;
    }
}
